package com.rfid.emergencywarehouse.adapter;

import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.rfid.base.base.BaseAdapter;
import com.rfid.emergencywarehouse.R;
import com.rfid.emergencywarehouse.entity.AssetOrder;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class AssetOrderAdapter extends BaseAdapter<AssetOrderAdapter.MyHolder, AssetOrder> {


    public AssetOrderAdapter(List<AssetOrder> data) {
        super(data);
    }

    @Override
    protected int getLayout() {
        return R.layout.item_asset_order;
    }

    @Override
    protected MyHolder getViewHolder(View view) {
        return new MyHolder(view);
    }

    @Override
    protected void bindView(MyHolder holder, int position, AssetOrder t) {
        AssetOrder order = mData.get(position);
        holder.order_num.setText(String.format("申请单号：%s",order.getOriginOrderNo()));
        holder.lqr.setText(String.format("领取人：%s",order.getPickingUserName()));
        holder.date.setText(String.format("申请时间： %s",order.getCreateTime()));
        holder.creator.setText(String.format("由%s提取的申请单",order.getCreateUserName()));
        holder.status.setText(getSatusStr(order));
    }

    private String getSatusStr(AssetOrder order) {
        if (order.getState() < 70 && order.getOrderState() < 2) {
            return "待领取";
        }
        return "已领取";
    }

    public class MyHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.lqr)
        TextView lqr;
        @BindView(R.id.order_num)
        TextView order_num;
        @BindView(R.id.status)
        TextView status;
        @BindView(R.id.date)
        TextView date;
        @BindView(R.id.creator)
        TextView creator;
        @BindView(R.id.detail)
        TextView detail;
        public MyHolder(@NonNull View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
